<template>
	<view class="boxes">
		<!-- 医馆信息 -->
		<view v-if="identity == 2">
			<view class="infoWrap">
				<view>
					<view class="infoLeft">
						<img v-if="myInfo.avatar" :src="myInfo.avatar" mode=""></img>
						<img v-else src="../../static/bg/Myprescription1.png" mode="widthFix"></img>
						<view class="top_nameWrap">
							{{myInfo.name}} <text>{{myInfo.zhicheng}}</text>
						</view>
					</view>
					<view class="msg">默认展示当天问诊订单，更多订单前往我的-我的订单查看</view>
				</view>
				<view>
					<view class="speed" @click="nowSpeed">快捷开方</view>
					<view class="speed sp2" @click="nowCentre">会诊中心</view>
				</view>
			</view>
			<wuc-tab :tab-list="tabList" :tabCur.sync="TabCur" @change="tabChange" textFlex
				style="margin-bottom: 20upx;">
			</wuc-tab>
			<view class="tabchange">
				<Tab1 :refresh="refresh" v-if="TabCur == 0"></Tab1>
				<Tab2 :refresh2="refresh2" :refresh="refresh" v-else-if="TabCur == 1"></Tab2>
				<Tab3 :refresh3="refresh3" v-else></Tab3>
			</view>
		</view>
		<!-- 患者信息 -->
		<view v-if="identity == 1">
			<view class="infoMsg">
				<view class="uniFlex2">
					<view style="flex-shrink: 0;">医馆名称：</view>
					<view>{{companyList.title}}</view>
				</view>
				<view @click.stop="call">客服电话：{{companyList.tel}}</view>
				<view>医馆地址：{{companyList.province}}{{companyList.city}}{{companyList.area}}</view>
				<view class="uniFlex2">
					<view style="flex-shrink: 0;">详细地址：</view>
					<view>{{companyList.address}}</view>
				</view>
				<view class="uniFlex2">
					<view>营业时间：</view>
					<view>
						<view>上午：{{companyList.business_morning}}</view>
						<view>下午：{{companyList.business_afternoon}}</view>
						<view>晚上：{{companyList.business_night}}</view>
					</view>
				</view>
				<img @click.stop="imgcode" class="imgcode" src="@/static/bg/code.png" alt="">
				
			</view>
			<uni-popup ref="popup" :mask-click="false">
				<view class="qcode">
					<img :src="qcode" alt="">
					<view class="text">长按关注公众号，以便提供更好的服务。</view>
					<view class="botton" @click="close">关闭</view>
				</view>
			</uni-popup>
			
			<tab4></tab4>
		</view>
	</view>
</template>

<script>
	import zzxCalendar from "@/components/zzx-calendar/zzx-calendar.vue";
	import WucTab from '@/components/wuc-tab/wuc-tab.vue';
	import Tab1 from '@/components/tab1.vue';
	import Tab2 from '@/components/tab2.vue';
	import Tab3 from '@/components/tab3.vue';
	import tab4 from '@/components/tab4.vue';
	import commonUtil from "../../components/utils/format.js";
	import {
		myInfo,
		getcompany,
		get_company_doctors,
	} from '../../request/api.js'
	export default {
		components: {
			WucTab,
			Tab1,
			Tab2,
			Tab3,
			tab4
		},
		data() {
			return {
				identity: '', //当前登录身份
				qcode:'',//二维码
				TabCur: 0,
				tabList: [{
					name: '待接诊'
				}, {
					name: '问诊中'
				}, {
					name: '已结束'
				}],
				companyList: {

				},
				// 医馆信息
				companyList: {
					title: "",
					tel: "",
					business_morning: "",
					business_afternoon: "",
					business_night: "",
					province: "",
					city: "",
					area: "",
					address: "",
				},

				// 医生信息
				myInfo: {
					avatar: '../../static/bg/Myprescription1.png',
					name: '',
					zhicheng: '',
					jiezhen: 0,
					yuyuenum: 0,
					huifu: 0
				},
				refresh: true, //父传子参数
				refresh2: true, //父传子参数
				refresh3: true, //父传子参数
			}
		},
		onLoad() {
			this.$nextTick(() => {
				this.identity = uni.getStorageSync('identity')
				if (uni.getStorageSync('token')) {
					if (this.identity == 1) {
						this.getcompany()
					} else if (this.identity == 2) {
						this.getMyInfo()
					}
				}
			})
		},
		methods: {
			// 当前医馆信息
			getcompany() {
				let param = {
					id: uni.getStorageSync('companyId')
				}
				getcompany(param).then(res => {
					if (res.code === 200) {
						this.companyList = res.data;
						this.qcode = res.data.qcode;
						
						if (uni.getStorageSync('gz') == 0) {
							this.$refs.popup.open('top')
						}
						
						uni.setNavigationBarTitle({
							title: res.data.title
						})
					}
				})
			},
			close(){
				uni.setStorageSync('gz',1)
				this.$refs.popup.close()
			},
			// 获取医生信息
			getMyInfo() {
				myInfo().then(res => {
					if (res.code === 200) {
						this.myInfo = res.data
					}
				})
			},
			// 快捷开方
			nowSpeed(){
				uni.navigateTo({
					url:'/pages/guahao/kaifang'
				})
			},
			// 会诊中心
			nowCentre(){
				uni.navigateTo({
					url:'/pages/centrum/centrum'
				})
			},
			// 切换状态
			tabChange(index) {
				this.TabCur = index;
				// console.log(this.TabCur)
			},
			// 问诊详情
			gopatientDetail() {
				uni.navigateTo({
					url: '../patientDetail/patientDetail'
				})
			},
			// 拨打电话
			call() {
				let phone = this.companyList.tel
				uni.makePhoneCall({
					phoneNumber: phone, //电话号码
					success: function(e) {
						console.log(e);
					},
					fail: function(e) {
						console.log(e);
					}
				})
			},
			// 分享码
			imgcode(){
				uni.navigateTo({
					url:'/pages/imgcode/imgcode'
				})
			}
		},
		// 父组件触底传递给子组件
		onReachBottom() {
			if (this.TabCur === 0) {
				this.refresh = !this.refresh
			} else if (this.TabCur === 1) {
				this.refresh2 = !this.refresh2
			} else if (this.TabCur === 2) {
				this.refresh3 = !this.refresh3
			}
		},
	}
</script>

<style lang="scss" scoped>
	page {
		background: #f8f8f8;
	}

	.boxes {
		background: #f8f8f8;

		// 医生端展示个人信息
		.infoWrap {
			padding: 30upx;
			display: flex;
			align-items: center;
			justify-content: space-between;

			.infoLeft{
				display: flex;
				align-items: center;
				
				img {
					width: 112upx;
					height: 112upx;
					margin-right: 24upx;
					border-radius: 50%;
				}
				
				.top_nameWrap {
					font-size: 40upx;
					font-family: Source Han Sans CN;
					font-weight: bold;
					color: #000000;
					margin-bottom: 12upx;
				
					text {
						font-size: 28upx;
						margin-left: 12upx;
					}
				}
			}
			
			.msg{
				font-size: 26rpx;
				padding: 0 25rpx;
				color: #0D9595;
			}
			
			.speed {
				width: 88px;
				background: #FDF4F5;
				border: 1px solid #F86C53;
				border-radius: 16px;
				font-size: 14px;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #F86C53;
				padding: 4px 0;
				text-align: center;
			}
			.sp2{
				color: #808EFE;
				border: 1px solid #808EFE;
				margin-top: 20upx;
			}
		}

		// 患者端展示医馆信息
		.infoMsg {
			font-size: 30upx;
			margin-bottom: 30upx;
			line-height: 170%;
			background: #ffffff;
			padding: 30upx;
			position: relative;
			
			.imgcode{
				position: absolute;
				top: 25upx;
				right: 35upx;
				flex-shrink: 0;
			}
		}
		
		.qcode{
			width: 580upx;
			height: 500upx;
			background: #ffffff;
			text-align: center;
			border-radius: 20upx;
			padding: 20upx;
			
			img{
				width: 300upx;
				height: 300upx;
				margin: 0 auto;
			}
			.text{
				font-size: 26upx;
			}
			.botton{
				width: 88%;
				height: 80upx;
				line-height: 80upx;
				background: #eee;
				margin: 0 auto;
				margin-top: 20upx;
			}
		}
	}
</style>
